package com.servlet.uploaddownload;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/ListDownload")
public class DownloadListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String userName = (String) req.getSession().getAttribute("userName");
		String fileRepository = "C:/usersjsp/" + userName;
		
		File path = new File(fileRepository);
		File[] files = path.listFiles();
		req.setAttribute("listFiles", files);
		req.getRequestDispatcher("UploadDownloadForm.jsp").forward(req, resp);
	}
}
